<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
  <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="<%=basePath%>Js/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/mycss/bootstrap.min.css" />
</head>

<script type="text/javascript">

//删除楼层
function deleteFloor(){
	
	var floor = $("#floor").find("option:selected").text();
	
	$.ajax({
		type:"post",
		url:"<%=basePath%>deleteFloor.do",
			data : {
				"floor" : floor,
			},
			dataType : "text",
			success : function(result) {
				if (result == "1") {
					alert("删除楼层成功")
					window.location.href="selectFloor.do";
				} else {
					alert("删除楼层失败")
				}
			},
			error : function() {
				alert("系统故障")
			}

		})	
}

//添加楼层
function addFloor(){
	
	var floor = $("#inpfloor").val();
	
	if(floor == ""){
		alert("输入不能为空")
	}else{
		$.ajax({
			type:"post",
			url:"addFloor.do",
			data:{
				"floor":floor,
			},
			dataType:"text",
			success:function(result){
				
				if(result == "1"){
					alert("添加楼层成功")
					window.location.href="selectFloor.do";
				}else if(result == "2"){
					alert("楼层已存在")
				}else{
					alert("添加失败")
				}
				
			},
			error:function(){
				alert("系统故障")
			}
		})
	}
	
	
}


</script>

<body>
<div style="border-width: 10px;border-color: beige;border-style: double;
		border-radius: -webkit-calc(background-color: );padding: 10px;margin:50px;left: 200px; top: 100px; width: 800px;">
<hr><h4 align="center" style="color: #4981F8;" align="center">楼层管理</h4><hr><br><br>
		<table >
			<tr>
				<td>选择楼层：</td>
				<td><select name="floor" id="floor" class="form-control">

						<c:forEach items="${floorlist}" var="floorlist">

							<option value="1">${floorlist.floor}</option>
						</c:forEach>

				</select></td>
				<td><button onclick="deleteFloor()" type="button" class="btn btn-success">删除楼层</button></td>
			</tr>

		</table><br>
		<span style="color: red;font-size: 20px">*删除楼层会删除楼层房间，请谨慎操作</span><br><br>
		
		<h5>添加楼层</h5>
		<table>
		<tr>
		<td><input type="text" class="form-control" id="inpfloor" placeholder="请输入楼层"></td>
		<td><button type="button" class="btn btn-success" onclick="addFloor()">添加</button></td>
		</tr>
		</table>
	</div>
	
</body>
</html>